﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ShSoft.Common.PoweredByLee;
using ShSoft.Infrastructure.EntityBase;

namespace WarehouseSystem.Domain.Entities
{
    /// <summary>
    /// 出入库单据
    /// </summary>
    public class ICStockBill : AggregateRootEntity
    {
        #region  # 构造器

        #region 01.无参构造器
        /// <summary>
        /// 无参构造器
        /// </summary>
        protected ICStockBill()
        {
            //初始化导航属性
            this.Details = new HashSet<ICStockBillDetail>();
        }

        #endregion

        #region 02.创建出入库单据构造器

        /// <summary>
        /// 创建出入库单据构造器
        /// </summary>
        /// <param name="details">单据详细集</param>
        /// <param name="distribution">配送信息</param>
        /// <param name="operateId">操作人ID</param>
        /// <param name="operateName">操作人姓名</param>
        /// <param name="createTime">出入库时间</param>
        /// <param name="inOutType">出入库类型</param>
        /// <param name="remark">备注</param>
        public ICStockBill(ICollection<ICStockBillDetail> details,DistributionInformation distribution, Guid operateId, string operateName, DateTime createTime,bool inOutType, string remark)
            : this()
        {
            

            this.LotNumber = "自动生成";
            this.OperateId = operateId;
            this.OperateName = operateName;
            this.CreateTime = createTime;
            this.InOutType = inOutType;
            this.Remark = remark;
            this.Details.AddRange(details);
            this.Distribution = distribution;
            //初始化关键字
            this.InitKeywords();
        }

        #endregion

        #endregion

        #region # 属性

        #region 出入库时间 —— DateTime CreateTime
        /// <summary>
        /// 出入库时间
        /// </summary>
        public DateTime CreateTime { get; private set; }

        #endregion

        #region 批号 —— string LotNumber
        /// <summary>
        /// 批号
        /// </summary>
        public string LotNumber { get; private set; }

        #endregion

        #region 操作人Id —— Guid OperateId
        /// <summary>
        /// 操作人Id
        /// </summary>
        public Guid OperateId { get; private set; }

        #endregion

        #region 操作人姓名 —— string OperateName
        /// <summary>
        /// 操作人姓名
        /// </summary>
        public string OperateName { get; private set; }

        #endregion

        #region 出入库类型  需修改为枚举
        /// <summary>
        /// 出入库类型
        /// </summary>
        public bool InOutType { get; set; }
        #endregion

        #region 备注 —— string Remark
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; private set; }

        #endregion

        #region 导航属性 - 出入库详细集 —— ICollection<ICStockBillDetail> Details
        /// <summary>
        /// 导航属性 - 出入库详细集
        /// </summary>
        public virtual ICollection<ICStockBillDetail> Details { get; private set; }
        #endregion

        #region 导航属性 - 配送信息 —— DistributionInformation Distribution
        /// <summary>
        /// 导航属性 - 配送信息
        /// </summary>
        public virtual DistributionInformation Distribution { get; private set; }
        #endregion

        #endregion

        #region 方法

        //public

        #region 获取商品信息 ——



        #endregion

        //private

        #region 初始化关键字 —— void InitKeywords()
        /// <summary>
        /// 初始化关键字
        /// </summary>
        private void InitKeywords()
        {
            StringBuilder keywordsBuilder = new StringBuilder();
            keywordsBuilder.Append(base.Number);
            keywordsBuilder.Append(base.Name);

            base.SetKeywords(keywordsBuilder.ToString());
        }
        #endregion

        #endregion
    }
}
